﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
//using HjKisTableAdapters;
using RGPWEB.App_Code.DAL;
using RGPWEB.App_Code.DAL.HjKisTableAdapters;

[System.ComponentModel.DataObject]
public class apriceBll
 {
    private apriceTableAdapter _productsAdapter = null;
    protected apriceTableAdapter Adapter
        {
            get
            {
                if (_productsAdapter == null)
                    _productsAdapter = new apriceTableAdapter();

                return _productsAdapter;
            }
        }


    [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
    public RGPWEB.App_Code.DAL.HjKis.apriceDataTable GetData()
    {
        return Adapter.GetData();
    }

    [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
    public RGPWEB.App_Code.DAL.HjKis.apriceDataTable GetDataByFnumber(string _fnumber)
    {
        return Adapter.GetDataByFnumber(_fnumber);
    }

    [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
    public RGPWEB.App_Code.DAL.HjKis.apriceDataTable GetDataByFitemid(Int32 _fitemid)
    {
        return Adapter.GetDataByFitemid(_fitemid);
    }



    [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update, true)]
    public bool UpdateQuery(string fnumber, string fname, string fmodel, decimal fplanprice, string fnote, short fdeleted, Int32 original_fitemid)
    {

        RGPWEB.App_Code.DAL.HjKis.apriceDataTable Mcodes = Adapter.GetDataByFitemid(original_fitemid);
        if (Mcodes.Count == 0) return false;

        RGPWEB.App_Code.DAL.HjKis.apriceRow mcode = Mcodes[0];

        //  mcode.id = original_id;
        //mcode.fnumber = fnumber;
        //mcode.fname = fname;
        //mcode.fmodel = fmodel;
        mcode.fplanprice = fplanprice;
        //mcode.fnote = fnote;
        

        

        // Update the product record
        int rowsAffected = Adapter.Update(mcode);

        // Return true if precisely one row was updated, otherwise false
        return rowsAffected == 1;


    }


 }
